package com.mogu.blogs.controller;

import com.mogu.blogs.service.ArchiveService;
import com.mogu.entity.TBlog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Papa on 2020/6/18.
 */
@RestController
@Api(value = "归档相关接口", tags = {"按日期分档相关接口"})
@RequestMapping("/archive")
public class ArchiveController {
    @Autowired
    ArchiveService archiveService;
    @RequestMapping("/getBlogByMonth/{month}")
    @ApiOperation(value = "通过Month查询博客内容" , notes = "通过month查询博客内容")
    public String getBlogByMonth(@PathVariable("month") String month){
         TBlog articleByMonth = archiveService.getArticleByMonth(month);
        System.out.println(articleByMonth.toString());
        if(articleByMonth!=null){
            return "success";
        }
        return "fail";
    }
//    @RequestMapping("/getYearAndMonth")
//    @ApiOperation(value = "通过日期查询博客内容" , notes = "通过month查询博客内容")
//    public List<String> findAllYearAndMonth(){
//        List<Timestamp> allYearAndMonth = archiveService.findAllYearAndMonth();
//        System.out.println(allYearAndMonth);
//        List<String> list = new ArrayList<>();
//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月");
//        String s = dateFormat.format(allYearAndMonth);
//        list.add(s);
//        for (Date date : allYearAndMonth) {
//            System.out.println(date);
//          list.add(dateFormat.format(date));
//        }
//        System.out.println(list);
//
//       return  list;
//    }
}
